package com.kasax.plugin.app.visitor.clickclass

import com.kasax.plugin.app.LogUtils
import org.objectweb.asm.MethodVisitor
import org.objectweb.asm.Opcodes

class ClickMethodVisitor extends MethodVisitor {
    final String TAG = "ClickMethodVisitor"

    ClickMethodVisitor(MethodVisitor mv) {
        super(Opcodes.ASM7, mv)
    }

    @Override
    void visitCode() {
        super.visitCode()
        LogUtils.d(TAG, "------------ ------------   ClickMethodVisitor visitCode 开始  ------------ ------------  ")
        // Log.d中的TAG
        mv.visitLdcInsn("zzg")
        // Log.d中的Message
        mv.visitLdcInsn("这里是通过ClickMethodVisitor插桩注入的一个测试方法")
        mv.visitMethodInsn(
                Opcodes.INVOKESTATIC,
                "android/util/Log",
                "d",
                "(Ljava/lang/String;Ljava/lang/String;)I",
                false
        )
        mv.visitInsn(Opcodes.POP)
        LogUtils.d(TAG, "------------ ------------   ClickMethodVisitor visitCode 结束  ------------ ------------  ")
    }
}